home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
util
/
cdity
/
ModeProSrc.lha
/
Daemon
/
MPPatch.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-03-13
|
49KB
|
1,439 lines
#define DEBUG
#include <debug.h>
#include "MP.h"
//#include "/modepro.h"
#include <graphics/videocontrol.h>
#include <graphics/displayinfo.h>
#include "patchdata.h"
#ifdef DEBUG
#define ADD_DEBUG_CODE
#endif
void WaitForReply(struct Message *Msg);
//ULONG Colors[]={1<<16|0,~0,0,0,0};
#define HAM_EHB_DP_KEY (HAM_KEY | 0x400 | EXTRAHALFBRITE_KEY)
// DualPF
//BOOL MPSem->Debug=FALSE;
/* kprintf
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
}
#endif
*/
#define AllocOpenNode(on) (on ? on: AllocMem(sizeof(struct OpenNode),MEMF_CLEAR|MEMF_PUBLIC))
void CatchDNode(ULONG Dest, UBYTE *Name, struct DefaultNode *SrcNode);
LONG MyGetProgramName(STRPTR Buffer, LONG Len);
extern LONG InPatch;
extern UBYTE ModePro[];
extern ULONG CenterAll;
extern CxObj *Broker;
extern struct MsgPort *BrokerPort;
extern BOOL V39;
extern BYTE PublicSignal;
extern struct MPSem *MPSem;
extern struct Process *MPTask;
extern struct MsgPort *CatchPort;
extern struct Screen ASM *(*OldOpenScreen)(REG __a0 struct NewScreen *,
REG __a6 struct IntuitionBase *);
extern struct Screen ASM *(*OldOpenScreenTagList)(REG __a0 struct ExtNewScreen *ns,
REG __a1 struct TagItem *taglist,
REG __a6 struct IntuitionBase * );
ULONG WBPromotable;
/*********************************************************************************/
struct Screen ASM __saveds *NewOpenScreen(REG __a0 struct ExtNewScreen *ns,
REG __a6 struct IntuitionBase *IBase)
{
struct TagItem *taglist;
struct Screen *scr;
ULONG stack1=0xc0de0000;
DoNothing(&stack1);
InPatch++;
taglist=0;
if(ns)
{
if(ns->Type & NS_EXTENDED)
taglist=ns->Extension;
}
scr=NewOpenScreenTagList(ns,taglist,IBase );
InPatch--;
return(scr);
}
struct DefaultNode CenterAllNode={0};
struct Screen ASM __saveds *NewOpenScreenTagList(REG __a0 struct ExtNewScreen *ns,
REG __a1 struct TagItem *TagList,
REG __a6 struct IntuitionBase *IBase)
{
struct Screen *RetScreen;
struct PatchData *pd;
struct TagItem fonttags[]= { TA_DeviceDPI , (1<<16) | 1 , TAG_DONE,0 };
ULONG stack1=0xc0de0001;
DoNothing(&stack1);
/**** END VARS ****/
InPatch++;
ObtainSemaphoreShared(&MPSem->ListSem);
// ObtainSemaphore(&MPSem->NodeSem);
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
DKP("\n");
DKP("OpenScreenX()\n");
}
#endif
if(!MPSem->Enabled && !FindTagItem(SA_ModeProNode,TagList)) // if we find SA_ModeProNode then make the screen.
{
RetScreen=OldOpenScreenTagList(ns,TagList,IBase);
DEBUG_CODE(DKP(" RetVal=%0x08lx (unpromoted 1)\n",RetScreen););
ReleaseSemaphore(&MPSem->ListSem);
// ReleaseSemaphore(&MPSem->NodeSem);
InPatch--;
return(RetScreen);
}
if(pd=AllocVec(sizeof(struct PatchData),MEMF_CLEAR | MEMF_PUBLIC))
{
pd->NullPens[0]=(~0);
pd->Promote=TRUE;
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
DKP("PatchData=%8lx\n",pd);
DKP("struct NewScreen : %08lx\n",ns);
if(ns)
{
DKP(" LeftEdge : %6ld TopEdge : %6ld\n", ns->LeftEdge, ns->TopEdge);
DKP(" Width : %6ld Height : %6ld\n", ns->Width, ns->Height);
DKP(" Depth : %6ld\n",ns->Depth);
DKP(" DetailPen : %3ld BlockPen : %3ld\n",ns->DetailPen, ns->BlockPen);
DKP(" ViewMode : 0x%08lx Type : %6ld Font : 0x%08lx\n",ns->ViewModes, ns->Type, ns->Font);
DKP(" DefaultTitle : %s\n", (ns->DefaultTitle ? ns->DefaultTitle:""));
DKP(" Gadgets : 0x%08lx CustomBitmap : 0x%08lx\n",ns->Gadgets, ns->CustomBitMap);
if(ns->Type & NS_EXTENDED)
{
DKP(" NOTE : NS_EXTENDED set \n");
}
}
if(TagList)
{
DKP(" TagList:\n");
PrintTags(TagList);
}
}
#endif
/* initialize everything */
/* 0'ed by MEMF_CLEAR
pd->DNode=NULL;
pd->EHB_HAM=0;
pd->TagNumber=0;
pd->ScrTitle=NULL;
pd->OpenNode=NULL;
pd->HasCustomBM=pd->Changed=pd->ModeChanged=pd->SetLook3D=pd->OverscanType=pd->Interleave=0L;
pd->SetDepth=FALSE;
pd->IsWorkbench=0;
*/
pd->Depth=1;
pd->Width=pd->Height=pd->AutoScroll=-1;
pd->ModeID=INVALID_ID; // (4.56.7)
pd->ScreenPens=pd->NullPens;
pd->TaskName=FindTask(0)->tc_Node.ln_Name;
if(MyGetProgramName(pd->CLI_Name,CLI_NAMESIZE-1)) /* Get cli program's name */
{/* This causes a hit with CED */
DEBUG_CODE(DKP("GetProgramName=\"%s\"\n",pd->CLI_Name););
if(pd->CLI_Name[0]!=0) /* make sure pd->CLI_Name contains something */
pd->TaskName=pd->CLI_Name;
}
/* Initialization Done */
/**** Extract screen info from ns and TagList ****/
if(ns)
{
pd->StoredFont =ns->Font;
pd->Width =ns->Width;
pd->Height =ns->Height;
pd->ModeID =ns->ViewModes;
pd->Depth =ns->Depth;
pd->ScrTitle =ns->DefaultTitle;
if(ns->Type & CUSTOMBITMAP)
{
pd->HasCustomBM =ns->CustomBitMap;
}
//pd->IsWorkbench =(ns->Type & SCREENTYPE)==WBENCHSCREEN;// (4.61.1)
}
if(TagList)
{
pd->HasCustomBM=(struct BitMap *)GetTagData(SA_BitMap, (ULONG)pd->HasCustomBM, TagList);
pd->Width =GetTagData(SA_Width, pd->Width, TagList);
pd->Height =GetTagData(SA_Height, pd->Height, TagList);
pd->AutoScroll =GetTagData(SA_AutoScroll,pd->AutoScroll, TagList);
pd->OverscanType =GetTagData(SA_Overscan, pd->OverscanType, TagList);
pd->ModeID =GetTagData(SA_DisplayID, pd->ModeID, TagList);
pd->Depth =GetTagData(SA_Depth, pd->Depth, TagList);
pd->ScrTitle =(UBYTE *)GetTagData(SA_Title, (ULONG)pd->ScrTitle, TagList);
pd->IsWorkbench =(GetTagData(SA_Type, pd->IsWorkbench, TagList) & SCREENTYPE)==WBENCHSCREEN;
pd->Interleave =GetTagData(SA_Interleaved,pd->Interleave, TagList);
if(pd->Tag=FindTagItem(SA_Overscan,TagList))
if(!FindTagItem(SA_DClip,TagList))
pd->OverscanType=pd->Tag->ti_Data;
if(pd->Tag=FindTagItem(SA_Pens,TagList))
{
pd->ScreenPens=(UWORD *)(pd->Tag->ti_Data);
}
}
DEBUG_CODE(DKP("IsWorkbench=%ld\n",pd->IsWorkbench););
if(GetDisplayInfoData(0,(UBYTE *)&pd->DispInfo,sizeof(pd->DispInfo),DTAG_DISP,pd->ModeID))
{
pd->EHB_HAM=pd->DispInfo.PropertyFlags & (DIPF_IS_DUALPF | DIPF_IS_HAM |
DIPF_IS_PF2PRI | DIPF_IS_EXTRAHALFBRITE);
}
if(!pd->ScrTitle)
{
pd->ScrTitle=GetString(MSG_ITEM_NO_NAME); /* Just in case ther isn't a pd->ScrTitle */
}
ObtainSemaphore(&MPSem->NodeSem);
if(pd->DNode=(struct DefaultNode *)GetTagData(SA_ModeProNode, (ULONG)MatchDNode(pd->TaskName, pd->ScrTitle, pd->ModeID) ,TagList))
{
pd->DNode=DupDNode(pd->DNode); // Duplicate the node so we can release the node semaphore
}
ReleaseSemaphore(&MPSem->NodeSem);
if(!pd->DNode)
{
if(!pd->IsWorkbench || WBPromotable)
{
UBYTE *modename;
STRPTR dname="";
if(MPSem->CatchScreens && MPSem->Enabled)
{
if(modename=GetModeName(pd->ModeID));
{
//if(EZReq(0,0,ModePro,GetString(MSG_NEW_SCREEN_1),GetString(MSG_NEW_SCREEN_1_BUTTONS),pd->ScrTitle,pd->TaskName,(ULONG)modename))
{
ULONG listnum=1,button;
if(button=EZReq(0,0,ModePro,GetString(MSG_NEW_SCREEN_2),GetString(MSG_NEW_SCREEN_2_BUTTONS),(ULONG)pd->ScrTitle,(ULONG)pd->TaskName,(ULONG)modename))
{
switch(button)
{
case 1:
dname=pd->ScrTitle;
listnum=1;
break;
case 2:
dname=pd->TaskName;
listnum=0;
break;
case 3:
dname=modename;
listnum=2;
break;
}
if(pd->DNode=AllocDefaultNode(dname))
{
LONG l;
pd->DNode->Type =listnum;
pd->DNode->Width =pd->Width;
pd->DNode->Height =pd->Height;
pd->DNode->AutoScroll =pd->AutoScroll;
pd->DNode->ModeSelect =0;
pd->DNode->ModeID =pd->DNode->OrigDisplayID =pd->ModeID;
pd->DNode->OverscanType =pd->OverscanType;
pd->DNode->Look3D =pd->SetLook3D;
pd->DNode->Flags =0;//DNF_NODELETE; /* So MPP can't delete me */
pd->DNode->Depth =pd->Depth;
for(l=0;l<DRIPENS && pd->ScreenPens[l]!=(~0);l++)
pd->DNode->Pens[l]=pd->ScreenPens[l];
pd->DNode=ForceEdit(pd->DNode);
}
}
}
FreeVec(modename);
}
}
}
}
if(!pd->DNode && MPSem->CenterAll)
{
CenterAllNode.Def_Node.ln_Name="CenterAll Dummy";
CenterAllNode.CenterFlags=MPSem->CenterAll;
pd->DNode=DupDNode(&CenterAllNode);
}
if(pd->DNode)
{
if(pd->DNode->Flags & DNF_NEVER_PROMOTE)
{
FreeDNode(pd->DNode);
pd->DNode=0;
}
else
if(!(pd->OpenNode=AllocVec(sizeof(struct OpenNode),MEMF_CLEAR|MEMF_PUBLIC)))
{
FreeDNode(pd->DNode);
pd->DNode=0;
}
else
{
pd->OpenNode->DN=pd->DNode;
}
}
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
if(pd->DNode)
PrintDefNode(pd->DNode);
}
#endif
if(!pd->DNode)
{
/* NOTE: if DNode=0 then there is no OpenNode */
RetScreen=OldOpenScreenTagList(ns,TagList,IBase);
FreeVec(pd);
DEBUG_CODE(DKP(" RetVal=%0x08lx (unpromoted 2)\n",RetScreen););
ReleaseSemaphore(&MPSem->ListSem);
InPatch--;
return(RetScreen);
}
if(!pd->IsWorkbench || WBPromotable)
{
switch(pd->DNode->ModeSelect)
{
case 0:
break;
case 1:
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
DKP("Promoting Monitor\n");
}
#endif
if(pd->ModeID > -1)
{
// if(V39)
{
pd->ModeID=MyBestModeID(BIDTAG_SourceID ,pd->ModeID,
BIDTAG_MonitorID ,pd->DNode->ModeID & MONITOR_ID_MASK,
TAG_SKIP ,(pd->SetDepth ? 0:1), // (4.56.11)
BIDTAG_Depth ,pd->Depth,
BIDTAG_DIPFMustHave ,pd->EHB_HAM,
TAG_SKIP ,(pd->Width==-1 ? 1:0),
BIDTAG_DesiredWidth ,pd->Width,
TAG_SKIP ,(pd->Height==-1 ? 1:0),
BIDTAG_DesiredHeight ,pd->Height,
TAG_DONE);
}
/* else
{
pd->ModeID= (pd->DNode->ModeID & MONITOR_ID_MASK) | (pd->ModeID & (~MONITOR_ID_MASK));
}*/
if(pd->ModeID==INVALID_ID)
pd->ModeID=pd->DNode->ModeID;
pd->ModeChanged=TRUE;
}
break;
case 2:
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
Delay(50*2);
DKP("Promoting ScreenMode\n");
}
#endif
pd->OverscanType =pd->DNode->OverscanType;
pd->Width =pd->DNode->Width;
pd->Height =pd->DNode->Height;
if(pd->DNode->Flags & DEPTH)
{
pd->Depth=pd->DNode->Depth;
pd->SetDepth=TRUE;
}
/* Pick a ModeID */ // (4.55.8)
if(FindDisplayInfo(pd->DNode->ModeID)) // 4.55 @3// (4.55.8)
{// (4.55.8)
pd->ModeID =pd->DNode->ModeID;// (4.55.8)
}// (4.55.8)
else // If the screen Mode doesn't exist try to find a new mode// (4.55.8)
{// (4.55.8)
// if(V39)// (4.55.8)
{// (4.55.8)
pd->ModeID=MyBestModeID(// (4.55.8)
BIDTAG_DesiredWidth, pd->Width,// (4.55.8)
BIDTAG_DesiredHeight, pd->Height,// (4.55.8)
BIDTAG_NominalWidth, pd->Width,// (4.55.8)
BIDTAG_NominalHeight, pd->Height,// (4.55.8)
(pd->SetDepth ? BIDTAG_Depth:TAG_IGNORE), pd->Depth,// (4.55.8)
TAG_DONE);// (4.55.8)
// (4.55.8)
}// (4.55.8)
}// (4.55.8)
pd->Changed=TRUE;
break;
case 3:
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
Delay(50*2);
DKP("Promoting with Requester\n");
}
#endif
if((pd->SReq=(struct ScreenModeRequester *)AllocAslRequestTags(ASL_ScreenModeRequest,
ASLSM_TitleText ,pd->ScrTitle,
ASLSM_DoWidth ,TRUE ,
ASLSM_DoHeight ,TRUE ,
ASLSM_DoOverscanType ,TRUE ,
ASLSM_DoAutoScroll ,TRUE ,
ASLSM_DoDepth ,pd->DNode->Flags & DEPTH,
ASLSM_InitialAutoScroll ,pd->DNode->AutoScroll,
ASLSM_InitialDisplayWidth ,pd->DNode->Width,
ASLSM_InitialDisplayHeight ,pd->DNode->Height,
ASLSM_InitialDisplayID ,pd->DNode->ModeID,
ASLSM_InitialDisplayDepth ,pd->DNode->Depth,
ASLSM_NegativeText ,GetString(MSG_REQ_USE_DEFAULT),
ASLSM_PropertyFlags ,0,
ASLSM_PropertyMask ,BADMODES,
TAG_END
)))
{
if(AslRequest(pd->SReq,NULL))
{
pd->ModeID =pd->SReq->sm_DisplayID /* | pd->EHB_HAM */; // Can't OR display ID's to get HAM or EHB!
pd->OverscanType =pd->SReq->sm_OverscanType;
pd->Width =pd->SReq->sm_DisplayWidth;
pd->Height =pd->SReq->sm_DisplayHeight;
pd->Changed =TRUE;
if(pd->DNode->Flags & DEPTH)
{
pd->Depth=pd->SReq->sm_DisplayDepth;
pd->SetDepth=TRUE;
}
}
else
{
pd->Promote=FALSE;
}
FreeAslRequest(pd->SReq);
}
break;
case MS_PROMOTE_BEST_MODE:// (4.56.9)
// (4.56.9)
DEBUG_CODE(DKP("Find Best Mode\n"););// (4.56.9)
// (4.56.9)
pd->OverscanType =pd->DNode->OverscanType;// (4.56.9)
pd->Width =pd->DNode->Width;// (4.56.9)
pd->Height =pd->DNode->Height;// (4.56.9)
// (4.56.9)
if(pd->DNode->Flags & DEPTH)// (4.56.9)
{// (4.56.9)
pd->Depth=pd->DNode->Depth;// (4.56.9)
pd->SetDepth=TRUE;// (4.56.9)
}// (4.56.9)
// (4.56.9)
// if(V39)// (4.56.9)
{//
ULONG mtag;
if((pd->DNode->ModeID & MONITOR_ID_MASK) == MONITOR_ID_MASK)
{// fake tag
mtag=TAG_IGNORE;
}
else
{
mtag=BIDTAG_MonitorID;
}
pd->ModeID=MyBestModeID(// (4.56.9)
mtag, (pd->DNode->ModeID & MONITOR_ID_MASK),// (4.56.9)
BIDTAG_DesiredWidth, pd->Width,// (4.56.9)
BIDTAG_DesiredHeight, pd->Height,// (4.56.9)
BIDTAG_NominalWidth, pd->Width,// (4.56.9)
BIDTAG_NominalHeight, pd->Height,// (4.56.9)
(pd->SetDepth ? BIDTAG_Depth:TAG_IGNORE), pd->Depth,// (4.56.9)
TAG_DONE);// (4.56.9)
}// (4.56.9)
// (4.56.9)
pd->Changed=TRUE;// (4.56.9)
break;// (4.56.9)
}/* end switch*/
if(!pd->Promote)
{ // 4.52
RetScreen=OldOpenScreenTagList(ns,TagList,IBase);
FreeDNode(pd->DNode);
FreeVec(pd->OpenNode);
FreeVec(pd);
DEBUG_CODE(DKP(" RetVal=%0x08lx (promotion cancelled)\n",RetScreen););
ReleaseSemaphore(&MPSem->ListSem);
InPatch--;
return(RetScreen);
}
/**** Setup promoted taglist ****/
if(pd->Promote)
{
pd->SetLook3D = pd->DNode->Look3D;
pd->Interleave =(pd->DNode->Flags & INTERLEAVE) | pd->Interleave;
pd->ScreenPens = pd->DNode->Pens;
pd->AutoScroll = pd->DNode->AutoScroll;
pd->BlankBorder = pd->DNode->Flags & DNF_BLANK_BORDER;
pd->Behind = pd->DNode->Flags & DNF_BEHIND;
if( (pd->DNode->Flags & DNF_FORCEPLANAR) &&
(pd->Width>0) &&
(pd->Height>0) &&
(!pd->HasCustomBM) &&
(V39) &&
(pd->Depth>0) )
{
if(pd->BitMap=AllocBitMap(pd->Width,pd->Height,pd->Depth,(pd->Interleave?BMF_INTERLEAVED:0)|BMF_STANDARD|BMF_DISPLAYABLE,0))
{
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
ULONG bmflags;
bmflags=GetBitMapAttr(pd->BitMap,BMA_FLAGS);
DKP("BitMap Flags %8lx\n",bmflags);
}
#endif
// pd->OpenNode->Flags|=ON_BITMAP; // 4.53 @5 can be determined by chaecking on->BitMap
pd->OpenNode->BitMap=pd->BitMap;
pd->NewTags[pd->TagNumber].ti_Tag=SA_BitMap;
pd->NewTags[pd->TagNumber].ti_Data=(ULONG)pd->BitMap;
pd->TagNumber++;
}
}
if(pd->Changed && !(pd->HasCustomBM))
{
if(pd->Width!=0)
{
pd->NewTags[pd->TagNumber].ti_Tag=SA_Width;
pd->NewTags[pd->TagNumber].ti_Data=pd->Width;
pd->TagNumber++;
}
if(pd->Height!=0)
{
pd->NewTags[pd->TagNumber].ti_Tag=SA_Height;
pd->NewTags[pd->TagNumber].ti_Data=pd->Height;
pd->TagNumber++;
}
if(FindTagItem(SA_DClip,TagList))
{ // if it specifies a dclip, i need to override it.
if(QueryOverscan(pd->ModeID,&pd->ODClip,pd->OverscanType))
{
pd->NewTags[pd->TagNumber].ti_Tag=SA_DClip;
pd->NewTags[pd->TagNumber].ti_Data=(ULONG)&pd->ODClip;
pd->TagNumber++;
}
}
else
{
pd->NewTags[pd->TagNumber].ti_Tag=SA_Overscan;
pd->NewTags[pd->TagNumber].ti_Data=pd->OverscanType;
pd->TagNumber++;
}
}
if(pd->ModeChanged || pd->Changed)
{
pd->NewTags[pd->TagNumber].ti_Tag=SA_DisplayID;
pd->NewTags[pd->TagNumber].ti_Data=pd->ModeID;
pd->TagNumber++;
}
if(pd->DNode->Flags & SHAREPENS)
{
pd->NewTags[pd->TagNumber].ti_Tag=SA_SharePens;
pd->NewTags[pd->TagNumber].ti_Data=TRUE;
pd->TagNumber++;
}
if(pd->SetDepth && !(pd->HasCustomBM) && !(pd->EHB_HAM))
{
pd->NewTags[pd->TagNumber].ti_Tag=SA_Depth;
pd->NewTags[pd->TagNumber].ti_Data=pd->Depth;
pd->TagNumber++;
}
if((pd->DNode->Flags & DNF_PALETTE) && pd->DNode->Palette && pd->DNode->Colors)
{
if(V39)
{
pd->Colors32[0]=pd->DNode->Colors<<16;
CopyMemQuick(pd->DNode->Palette,&pd->Colors32[1],pd->DNode->Colors*3*sizeof(ULONG));
pd->Colors32[pd->DNode->Colors*3+2]=0;
pd->NewTags[pd->TagNumber].ti_Tag=SA_Colors32;
pd->NewTags[pd->TagNumber].ti_Data=(ULONG)pd->Colors32;
pd->TagNumber++;
}
else
{
ULONG c;
for(c=0;c<pd->DNode->Colors;c++)
{
pd->ColorSpec[c].ColorIndex=c;
pd->ColorSpec[c].Red =pd->DNode->Palette[c].Red>>28;
pd->ColorSpec[c].Green =pd->DNode->Palette[c].Green>>28;
pd->ColorSpec[c].Blue =pd->DNode->Palette[c].Blue>>28;
}
pd->ColorSpec[c].ColorIndex=-1;
pd->NewTags[pd->TagNumber].ti_Tag=SA_Colors;
pd->NewTags[pd->TagNumber].ti_Data=(ULONG)pd->ColorSpec;
pd->TagNumber++;
}
}
switch(pd->DNode->FontType)
{
case SFONT_SYS:
if(ns) ns->Font=0;
pd->NewTags[pd->TagNumber].ti_Tag=SA_SysFont;
pd->NewTags[pd->TagNumber].ti_Data=1;
pd->TagNumber++;
break;
case SFONT_MP:
if(pd->DNode->Font.tta_Name)
{
// if(pd->OpenNode=AllocOpenNode(pd->OpenNode))
{
pd->OpenNode->Flags|=ON_FONT;
pd->NewTags[pd->TagNumber].ti_Tag =SA_Font;
pd->NewTags[pd->TagNumber].ti_Data =(ULONG)&pd->OpenNode->TA;
pd->TagNumber++;
if(pd->DNode->Flags & FIXASPECT && pd->ModeID != -1)
{
if(GetDisplayInfoData(NULL,(UBYTE *)&pd->DispInfo,sizeof(struct DisplayInfo),DTAG_DISP,pd->ModeID))
{
fonttags[0].ti_Data=(ULONG)pd->DispInfo.Resolution.x|(((ULONG)pd->DispInfo.Resolution.y)<<16);
pd->DNode->Font.tta_Style |= FSF_TAGGED;
pd->DNode->Font.tta_Tags =fonttags;
}
}
CloneTextAttr(&pd->DNode->Font,&pd->OpenNode->TA);
pd->DNode->Font.tta_Style &= (~FSF_TAGGED);
pd->DNode->Font.tta_Tags=NULL;
}
}
break;
}
if(pd->DNode->PubOptions==1 && pd->DNode->PubName)
{
ULONG error=FALSE;
struct TagItem badtags[]=
{
SA_BitMap, 1<<0,
// SA_PubName, 1<<1,
SA_PubSig, 1<<2,
SA_PubTask, 1<<3,
SA_BackFill, 1<<4,
TAG_DONE, 0
};
if(TagList) error =PackBoolTags(0,TagList,badtags);
if(ns) error|=(ns->Type & CUSTOMBITMAP);
if(error==0)
{
// if(pd->OpenNode=AllocOpenNode(pd->OpenNode))
{
struct OpenNode *won;
UBYTE number[8];
ULONG cnt=1,len;
strncpy(pd->OpenNode->PubName,pd->DNode->PubName,MAXPUBSCREENNAME);
pd->OpenNode->PubName[MAXPUBSCREENNAME]=0;
len=strlen(pd->OpenNode->PubName);
len=min(len,MAXPUBSCREENNAME-9);
ObtainSemaphore(&MPSem->OpenListSem);
won=(struct OpenNode *)MPSem->OpenList.lh_Head;
while(won->on_Node.ln_Succ)
{
if(cnt > 1)
{
number[0]='.';
stci_d(&number[1],cnt);
pd->OpenNode->PubName[len]=0;
strncat(pd->OpenNode->PubName,number,MAXPUBSCREENNAME);
pd->OpenNode->PubName[MAXPUBSCREENNAME]=0;
}
if(0==strcmp(pd->OpenNode->PubName,won->PubName))
{
won=(struct OpenNode *)MPSem->OpenList.lh_Head;
cnt++;
}
else
won=(struct OpenNode *)won->on_Node.ln_Succ;
}
ReleaseSemaphore(&MPSem->OpenListSem);
pd->OpenNode->ScreenTitle=CopyString(pd->ScrTitle,MEMF_PUBLIC);
// Name cloned, when app CloseScreen's this title replaces the app supplied one
pd->OpenNode->PubName[MAXPUBSCREENNAME]=0;
pd->OpenNode->Flags|= ON_PUBLIC | ON_OPEN;
pd->NewTags[pd->TagNumber].ti_Tag=SA_Title;// (4.58.1)
pd->NewTags[pd->TagNumber].ti_Data=(ULONG)pd->OpenNode->ScreenTitle;// (4.58.1)
pd->TagNumber++;// (4.58.1)
pd->NewTags[pd->TagNumber].ti_Tag=SA_PubName;
pd->NewTags[pd->TagNumber].ti_Data=(ULONG)pd->OpenNode->PubName;
pd->TagNumber++;
pd->NewTags[pd->TagNumber].ti_Tag=SA_PubSig;
pd->NewTags[pd->TagNumber].ti_Data=PublicSignal;
pd->TagNumber++;
pd->NewTags[pd->TagNumber].ti_Tag=SA_PubTask;
pd->NewTags[pd->TagNumber].ti_Data=(ULONG)MPTask;
pd->TagNumber++;
if(!(pd->OpenNode->Flags & ON_FONT))
{
struct TTextAttr *ot=NULL;
if(ns) ot=(struct TTextAttr *)ns->Font;
ot=(struct TTextAttr *)GetTagData(SA_Font,(ULONG)ot,TagList);
if(ot)
{
pd->OpenNode->Flags|=ON_FONT;
CloneTextAttr(ot,&pd->OpenNode->TA);
pd->NewTags[pd->TagNumber].ti_Tag =SA_Font;
pd->NewTags[pd->TagNumber].ti_Data=(ULONG)&pd->OpenNode->TA;
pd->TagNumber++;
}
}
}
}
}
} /* end - if(pd->Promote) */
}/* end - if(!pd->IsWorkbench) */
if(pd->IsWorkbench)
{ /* Yes, this is the Workbench screen */
// if(pd->OpenNode=AllocOpenNode(pd->OpenNode))
pd->OpenNode->Flags|=ON_WORKBENCH;
}
if(pd->Promote)
{
if(pd->SetLook3D)
{
LONG dp;
if(pd->DNode->Flags & DNF_3D_DEFAULT)
{
if(V39 && pd->Depth>1 && MPSem->PPrefsSet)
{
/* Use 4 color palette from prefs */
for(dp=0;dp<DRIPENS;dp++)
pd->DriPens[dp]=MPSem->PPrefs.pap_4ColorPens[dp] & 0xff;
pd->DriPens[dp]=~0;
}
else
pd->DriPens[0]=~0;
}
else
{
for(dp=0;dp<DRIPENS;dp++)
pd->DriPens[dp]=pd->DNode->Pens[dp] & 0xff;
pd->DriPens[dp]=~0;
}
pd->NewTags[pd->TagNumber].ti_Tag=SA_Pens;
pd->NewTags[pd->TagNumber].ti_Data=(ULONG)pd->DriPens;
pd->TagNumber++;
/*
if(pd->Depth==1)
{
pd->Depth=2; // This nolonger works
pd->SetDepth=TRUE;
// pd->NewTags[pd->TagNumber].ti_Tag=SA_Depth;
// pd->NewTags[pd->TagNumber].ti_Data=2;
// pd->TagNumber++;
}*/
}
if(pd->AutoScroll)
{
pd->NewTags[pd->TagNumber].ti_Tag=SA_AutoScroll;
pd->NewTags[pd->TagNumber].ti_Data=TRUE;
pd->TagNumber++;
}
if(pd->Behind)
{
pd->NewTags[pd->TagNumber].ti_Tag=SA_Behind;
pd->NewTags[pd->TagNumber].ti_Data=TRUE;
pd->TagNumber++;
}
if(pd->DNode->CenterFlags)
{
if(QueryOverscan(pd->ModeID,&pd->ODClip,pd->OverscanType))
//if(GetDisplayInfoData(NULL,(UBYTE *)&pd->DimInfo,sizeof(struct DimensionInfo),DTAG_DIMS,pd->ModeID))
{
if(pd->DNode->CenterFlags & 1)
{
if(pd->Width>-1 && pd->ODClip.MaxX > pd->ODClip.MinX)
{
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
DKP(" ODClip.MinX=%ld ODClip.MaxX=%ld Width=%ld\n",pd->ODClip.MinX,pd->ODClip.MaxX,pd->Width);
}
#endif
pd->NewTags[pd->TagNumber].ti_Tag=SA_Left;
pd->NewTags[pd->TagNumber].ti_Data=((pd->ODClip.MaxX-pd->ODClip.MinX)-pd->Width)/2+pd->ODClip.MinX;
pd->TagNumber++;
}
}
if(pd->DNode->CenterFlags & 2)
{
if(pd->Height>-1 && pd->ODClip.MaxX > pd->ODClip.MinX)
{
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
DKP(" ODClip.MinY=%ld ODClip.MaxY=%ld Height=%ld\n",pd->ODClip.MinY,pd->ODClip.MaxY,pd->Height);
}
#endif
pd->NewTags[pd->TagNumber].ti_Tag=SA_Top;
pd->NewTags[pd->TagNumber].ti_Data=((pd->ODClip.MaxY-pd->ODClip.MinY)-pd->Height)/2+pd->ODClip.MinY;
pd->TagNumber++;
}
}
#ifdef ADD_DEBUG_CODE
PrintOverscanInfo(pd);
#endif
}
}
if(pd->DNode->Flags & SCRHOTKEY && pd->DNode->HotKey)
{
// if(pd->OpenNode=AllocOpenNode(pd->OpenNode))
{
if(pd->OpenNode->HotKey=AllocVec(strlen(pd->DNode->HotKey)+1,MEMF_CLEAR|MEMF_PUBLIC))
{
strcpy(pd->OpenNode->HotKey,pd->DNode->HotKey);
pd->OpenNode->Cx=AddHotKey(Broker,BrokerPort,pd->OpenNode->HotKey,(ULONG)pd->OpenNode);
}
}
}
if(pd->Interleave && !(pd->HasCustomBM) && !pd->BitMap)
{
pd->NewTags[pd->TagNumber].ti_Tag=SA_Interleaved;
pd->NewTags[pd->TagNumber].ti_Data=TRUE;
pd->TagNumber++;
}
pd->NewTags[pd->TagNumber].ti_Tag=SA_MinimizeISG; /*** just a little extra for v40 ***/
pd->NewTags[pd->TagNumber].ti_Data=TRUE;
pd->TagNumber++;
/**** End Setup TagList ****/
// if(pd->OpenNode)
{
if(pd->OpenNode->Flags & ON_FONT)
pd->TextFont=OpenDiskFont((struct TextAttr *)&pd->OpenNode->TA);
}
} /* end - if(pd->Promote) */
if(TagList)
{
pd->NewTags[pd->TagNumber].ti_Tag=TAG_MORE;
pd->NewTags[pd->TagNumber].ti_Data=(ULONG)TagList;
}
else
{
pd->NewTags[pd->TagNumber].ti_Tag=TAG_DONE;
pd->NewTags[pd->TagNumber].ti_Data=0;
}
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
Delay(50*1);
DKP(" %ld new tags\n",pd->TagNumber);
DKP(" New TagList\n");
PrintTags(pd->NewTags);
DKP(" Opening\n");
}
#endif
RetScreen=OldOpenScreenTagList(ns,pd->NewTags,IBase);
if(ns)
{
ns->Font=pd->StoredFont;
}
if(RetScreen)
{
pd->OpenNode->Screen=RetScreen;
/*
// CyberKludge
if(pd->OpenNode->BitMap)
{
RetScreen->BitMap=*pd->OpenNode->BitMap;
RetScreen->RastPort.BitMap=pd->OpenNode->BitMap;
}
if(pd->HasCustomBM)
{
RetScreen->BitMap=*(struct BitMap *)pd->HasCustomBM;
RetScreen->RastPort.BitMap=pd->HasCustomBM;
}
*/
if(pd->BlankBorder)
{
ULONG vrt;
VideoControlTags(RetScreen->ViewPort.ColorMap,
VTAG_BORDERBLANK_SET, TRUE,
VTAG_IMMEDIATE ,&vrt,
TAG_DONE);
MakeScreen(RetScreen);
}
mpObtainPens(pd);
if(pd->OpenNode) // 4.53 @6
{
SendMPMsg(MP_SCREENOPENED,0,pd->OpenNode);
}
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
Delay(50*1);
DKP(" Screen Addr %8lx\n",RetScreen);
}
#endif
/**************/
if(pd->OpenNode->Flags & ON_FONT)
if(pd->TextFont)
CloseFont(pd->TextFont);
if(pd->OpenNode->Flags & ON_PUBLIC)
{
PubScreenStatus(RetScreen,0);
// pd->OpenNode->PubScreenLock=LockPubScreen(pd->OpenNode->PubName);
/*
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
DKP("PubScreenLock=%8lx\n",pd->OpenNode->PubScreenLock);
}
#endif
*/
}
ObtainSemaphore(&MPSem->OpenListSem);
AddHead(&MPSem->OpenList,(struct Node *)pd->OpenNode);
ReleaseSemaphore(&MPSem->OpenListSem);
DEBUG_CODE(DKP(" RetVal=%0x08lx (promoted)\n",RetScreen););
}
else
{
FreeOpenNode(pd->OpenNode);
if(!GetTagData(SA_ModeProNode,0,TagList))// (4.62.8)
{
RetScreen=OldOpenScreenTagList((struct ExtNewScreen *)ns,TagList,IBase);
}
DEBUG_CODE(DKP(" RetVal=%0x08lx (promotion failed, opened unpromoted)\n",RetScreen););
}
FreeVec(pd);
ReleaseSemaphore(&MPSem->ListSem);
InPatch--;
return(RetScreen);
}
// ReleaseSemaphore(&MPSem->NodeSem);
ReleaseSemaphore(&MPSem->ListSem);
InPatch--;
DEBUG_CODE(DKP(" RetVal=%0x08lx (failed)\n",0););
return(0);
}
/*
void CatchDNode(ULONG Dest, UBYTE *Name, struct DefaultNode *SrcNode)
{
struct DefaultNode *dnode;
LONG l;
if(dnode=AllocDefaultNode(Name))
{
dnode->Type =Dest;
dnode->Width =SrcNode->Width;
dnode->Height =SrcNode->Height;
dnode->AutoScroll =SrcNode->AutoScroll;
dnode->ModeSelect =0;
dnode->ModeID =SrcNode->ModeID;
dnode->OverscanType =SrcNode->OverscanType;
dnode->Look3D =SrcNode->Look3D;
dnode->Flags =SrcNode->Flags;
dnode->Depth =SrcNode->Depth;
/******* change to <= */
for(l=0;l<DRIPENS;l++)
dnode->Pens[l] =SrcNode->Pens[l];
PutMsg(CatchPort,(struct Message *)dnode);
}
return;
}
*/
/* Go into forced edit mode, user must edit this node before returning */
struct DefaultNode *ForceEdit(struct DefaultNode *DNode)
{
struct DefaultNode *retval;
struct MsgPort *rport;
struct MPMessage *mpm;
retval=0;
if(rport=CreateMsgPort())
{
if(mpm=AllocVec(sizeof(*mpm),MEMF_PUBLIC|MEMF_CLEAR))
{
if(ShowGUI())// (4.62.14)
{// (4.62.14)
/* Send ForcedEdit node to MPP */
mpm->Data=DNode;
mpm->Command=MP_FORCEDEDIT;
mpm->mp_Message.mn_Length=sizeof(struct MPMessage);
mpm->mp_Message.mn_ReplyPort=rport;
/* send message to ForceEditPort owner */
DEBUG_CODE(DKP("FE()-sending MP_FORCEDEDIT\n"););
ObtainSemaphore(&MPSem->PortSem);
PutMsg(&MPSem->PrefsToDoPort,(struct Message *)mpm);// (4.62.11)
ReleaseSemaphore(&MPSem->PortSem);
DEBUG_CODE(DKP("FE()-Waiting for replies\n"););
WaitForReply((struct Message *)mpm);
DEBUG_CODE(DKP("FE()-Reply received\n"););
switch(mpm->Code)
{
case MPFE_USEDELETE:
retval=DNode; // return DNode for use.
break;
case MPFE_NEVER:
DNode->Flags=DNF_NEVER_PROMOTE; // Set flag and give to MP
PutMsg(CatchPort,(struct Message *)DNode);
retval =0;
break;
case MPFE_SAVEUSE:
{
retval =DNode;
if(DNode =DupDNode(retval)) /* Duplicate, give copy to MP and then use orignal for promotion */
{
PutMsg(CatchPort,(struct Message *)DNode);
}
}
break;
case MPFE_CANCEL:
default:
/* Delete the new node */
FreeDNode(DNode);
}//END SWITCH
}
FreeVec(mpm);
}
DeleteMsgPort(rport);
}
return(retval);
}
void WaitForReply(struct Message *Msg)
{
struct Message *m;
struct MsgPort *port;
m=0;
port=Msg->mn_ReplyPort;
while(m!=Msg)
{
WaitPort(port);
m=GetMsg(port);
}
}
// 4.53 @7 renamed, parameter renamed
BOOL SendMPMsg(ULONG Command, ULONG Code, APTR Data)
{
struct MsgPort *mport;
struct MPMessage mpm;
if(mport=CreateMsgPort())
{
mpm.mp_Message.mn_ReplyPort=mport;
mpm.mp_Message.mn_Length=sizeof(mpm);
mpm.Command = Command;
mpm.Code = Code;
mpm.Data = Data;
PutMsg(MPSem->DaemonPort,(struct Message *)&mpm);
WaitForReply((struct Message *)&mpm);
DeleteMsgPort(mport);
return(1);
}
return(0);
}
/*
if(pd->DNode->Flags & SHAREPENS &&
pd->DNode->LockedPens &&
V39)
{
UBYTE *str,state=0,done=FALSE;
WORD num=0,num1=0,num2;
struct ColorMap *cm;
cm=RetScreen->ViewPort.ColorMap;
str=pd->DNode->LockedPens;
while(!done)
{
if(!*str) done=TRUE;
if(*str>='0' && *str<='9')
{
if(state==0)
state=1;
num=0;
while(*str>='0' && *str<='9')
{
num*=10;
num+=*str - '0';
str++;
}
switch(state)
{
case 1:
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
DKP(" obtaining pen %ld\n",num);
}
#endif
if(!pd->OpenNode->ObtainedPens[num])
{
if(-1!=ObtainPen(cm,num,0,0,0, PEN_EXCLUSIVE | PEN_NO_SETCOLOR)))
pd->OpenNode->ObtainedPens[num]=1;
}
break;
case 2:
for(num2=num1+1;num2<=num;num2++)
{
#ifdef ADD_DEBUG_CODE
if(MPSem->Debug)
{
DKP(" obtaining pen %ld\n",num2);
}
#endif
if(!pd->OpenNode->ObtainedPens[num2])
{
if(-1!=ObtainPen(cm,num2,0,0,0, PEN_EXCLUSIVE | PEN_NO_SETCOLOR))
pd->OpenNode->ObtainedPens[num2]=1;
}
}
break;
}
state=0;
}
if(*str==' ')
for(;*str==' ';str++);
else
if(*str=='-')
{
num1=num;
state=2;
str++;
}
else
str++;
}
}
*/
void DoNothing(ULONG *L)
{
}
#include <dos/dosextens.h>
LONG MyGetProgramName(STRPTR Buffer, LONG Len)// (4.56.6)
{// (4.56.6)
LONG bp,l;// (4.56.6)
struct Process *p;// (4.56.6)
struct CommandLineInterface *cli;// (4.56.6)
UBYTE *name;// (4.56.6)
// (4.56.6)
l=0;// (4.56.6)
// (4.56.6)
p=(struct Process *)FindTask(0);// (4.56.6)
Buffer[0]=0; // Add NULL // (4.56.6)
if(p->pr_Task.tc_Node.ln_Type==NT_PROCESS)// (4.56.6)
{// (4.56.6)
// We are a process// (4.56.6)
if(bp=(p->pr_CLI<<2))// (4.56.6)
{// (4.56.6)
cli=(struct CommandLineInterface *)bp;// (4.56.6)
if(name=(UBYTE *)(cli->cli_CommandName<<2)) // (4.56.6)
{// (4.56.6)
for(l=0;l<name[0] && l<Len-1;l++) // Copy BSTR to CSTR string// (4.56.6)
{// (4.56.6)
Buffer[l]=name[l+1]; // (4.56.6)
}// (4.56.6)
Buffer[l]=0; // Add NULL // (4.56.6)// (4.59.1)
}// (4.56.6)
}// (4.56.6)
}//
DEBUG_CODE(DKP("MyGetProgramName=%s\n",Buffer););
return(l);// (4.56.6)
}// (4.56.6)
/*
/* Go into forced edit mode, user must edit this node before returning */
struct DefaultNode *ForceEdit(struct DefaultNode *DNode)
{
struct DefaultNode *retval;
struct MsgPort *rport;
struct MPMessage *showgui,*mpm,*copympm;
retval=0;
if(rport=CreateMsgPort())
{
if(showgui=AllocVec(sizeof(*showgui),MEMF_PUBLIC|MEMF_CLEAR))
{
if(copympm=mpm=AllocVec(sizeof(struct MPMessage),MEMF_PUBLIC|MEMF_CLEAR))
{
/*
/* Instruct MP to open editor */
showgui->Command=MP_SHOWGUI;
showgui->mp_Message.mn_Length=sizeof(struct MPMessage);
showgui->mp_Message.mn_ReplyPort=rport;
DEBUG_CODE(DKP("FE()-sending MP_SHOWGUI\n"););
PutMsg(MPSem->DaemonPort,(struct Message *)showgui);// (4.62.12)
*/
ShowGUI();
/* Send ForcedEdit node to MPP */
mpm->Data=DNode;
mpm->Command=MP_FORCEDEDIT;
mpm->mp_Message.mn_Length=sizeof(struct MPMessage);
mpm->mp_Message.mn_ReplyPort=rport;
/* send message to ForceEditPort owner */
DEBUG_CODE(DKP("FE()-sending MP_FORCEDEDIT\n"););
ObtainSemaphore(&MPSem->PortSem);
PutMsg(&MPSem->PrefsToDoPort,(struct Message *)mpm);// (4.62.11)
ReleaseSemaphore(&MPSem->PortSem);
mpm=showgui=0;
while(mpm==0 && showgui==0)
{
struct MPMessage *m;
DEBUG_CODE(DKP("FE()-Waiting for replies\n"););
WaitPort(rport);
m=(APTR)GetMsg(rport);
switch(m->Command)
{
case MP_FORCEDEDIT:
DEBUG_CODE(DKP("FE()-recieved MP_FORCEDEDIT\n"););
mpm=m;
break;
case MP_SHOWGUI:
DEBUG_CODE(DKP("FE()-recieved MP_SHOWGUI\n"););
showgui=m;
if(showgui->Code==0)
{
// if showgui fails, remove mpm from the todo port and cancel it
ObtainSemaphore(&MPSem->PortSem);
Remove((struct Node *)copympm);
mpm=copympm;
mpm->Code=MPFE_CANCEL;
ReleaseSemaphore(&MPSem->PortSem);
}
break;
}
}
switch(mpm->Code)
{
case MPFE_USEDELETE:
retval=DNode; // return DNode for use.
break;
case MPFE_NEVER:
DNode->Flags=DNF_NEVER_PROMOTE; // Set flag and give to MP
PutMsg(CatchPort,(struct Message *)DNode);
retval =0;
break;
case MPFE_SAVEUSE:
{
retval =DNode;
if(DNode =DupDNode(retval)) /* Duplicate, give copy to MP and then use orignal for promotion */
{
PutMsg(CatchPort,(struct Message *)DNode);
}
}
break;
case MPFE_CANCEL:
default:
/* Delete the new node */
FreeDNode(DNode);
}//END SWITCH
FreeVec(mpm);
}
FreeVec(showgui);
}
DeleteMsgPort(rport);
}
return(retval);
}
*/